/**
 * @param {number[]} height
 * @return {number}
 */
var maxArea = function (height) {
  let max = 0
  let left = 0
  let right = height.length - 1
  let maxHeight = 0
  while (left !== right) {
    let minHeight = 0
    let area = 0
    if (height[left] > height[right]) {
      minHeight = height[right]
      area = minHeight * (right - left)
      right--
    } else {
      minHeight = height[left]
      area = minHeight * (right - left)
      left++
    }
    max = Math.max(area, max)
  }
  return max
}

console.log(maxArea([1, 3, 2, 5, 25, 24, 5]))
